package com.interrobang.anime;

import java.awt.Image;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author Justin Hand & Joshua Benson
 * This class represents an Anime object in the anime drinking game.
 *
 */

public class Anime implements Serializable, Comparable<Anime>
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2055296218014407436L;
	private String title;
	private int season;
	private int episodes;
	private ArrayList<Rule> rules;
	private Image image;

	/**
	 * constructor for the Anime class
	 * @param title the title of the Anime
	 * @param season the season number of the Anime
	 * @param episodes the number of episodes in the Anime
	 * @param rules the set of rules attributed to this Anime
	 */
	
	public Anime(String title, int episodes)
	{
		this.title = title;
		this.episodes = episodes;
		this.rules = new ArrayList<Rule>();
	}
	
	public Anime(String title, int season, int episodes, ArrayList<Rule> rules)
	{
		this.title = title;
		this.season = season;
		this.episodes = episodes;
		this.rules = rules;
		rules = new ArrayList<Rule>();
	}
	
	/**adds a rule to the Anime object's rule list
	 * @param rule
	 * 			the rule to set 
	 */			
	
	public void addRule(Rule rule)
	{
		rules.add(rule);
	}
	
	/**
	 * removes a rule from the Anime object's rule list
	 * @param rule
	 * 			the rule to set
	 */			
	
	public void removeRule(Rule rule)
	{
		rules.remove(rule);
	}
	
	public boolean equals(Object o)
	{
		if(o.getClass() != this.getClass())
			return false;
		else if(title.equalsIgnoreCase(((Anime) o).getTitle()))
			return true;
		else 
			return false;
	}
	
	/**
	 * @return the title
	 */
	public String getTitle() 
	{
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) 
	{
		this.title = title;
	}

	/**
	 * @return the season
	 */
	public int getSeason() 
	{
		return season;
	}

	/**
	 * @param season
	 *            the season to set
	 */
	public void setSeason(int season) 
	{
		this.season = season;
	}

	/**
	 * @return the episodes
	 */
	public int getEpisodes() 
	{
		return episodes;
	}

	/**
	 * @param episodes
	 *            the episodes to set
	 */
	public void setEpisodes(int episodes) 
	{
		this.episodes = episodes;
	}

	public ArrayList<Rule> getRules() {
		return rules;
	}

	@Override
	public int compareTo(Anime anime) 
	{
		String tit = anime.getTitle();
		tit.toUpperCase();
		String hold = title.toUpperCase();
		if(tit.charAt(0) > hold.charAt(0))
			return -1;
		else if(tit.charAt(0) < hold.charAt(0))
			return 1;
		else 
			return 0;
		
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public Image getImage() {
		return image;
	}

}
